package com.longge;

import java.util.HashMap;
import java.util.HashSet;
import java.util.stream.Stream;

/**
 * @创建人 xinglongge
 * @创建时间 2021/7/22
 * @描述
 */
public class FindTheDifference {

    public char findTheDifference(String s, String t) {

        char[] sChars = s.toCharArray();
        char[] tChars = t.toCharArray();
        HashMap<Character,Integer> sCharMap = new HashMap<>();
        for (char sChar : sChars) {
            sCharMap.put(sChar,sCharMap.getOrDefault(sChar,0)+1);
        }
        for (char tChar : tChars) {
            if (!sCharMap.containsKey(tChar)||sCharMap.get(tChar)==0) return tChar;
            sCharMap.put(tChar,sCharMap.get(tChar)-1);
        }
        return ' ';
    }
}
